#pragma once

#include <string>
#include <chrono>
#include <vector>

namespace yquote {

// 行情数据结构
struct QuoteData {
    std::string symbol;           // 股票代码
    double price;                 // 当前价格
    double open;                  // 开盘价
    double high;                  // 最高价
    double low;                   // 最低价
    double close;                 // 收盘价
    long long volume;             // 成交量
    double change;                // 涨跌额
    double change_percent;        // 涨跌幅
    std::chrono::system_clock::time_point timestamp; // 时间戳
    
    QuoteData() : price(0.0), open(0.0), high(0.0), low(0.0), 
                  close(0.0), volume(0), change(0.0), change_percent(0.0) {}
    
    QuoteData(const std::string& sym, double p) 
        : symbol(sym), price(p), open(p), high(p), low(p), close(p),
          volume(0), change(0.0), change_percent(0.0),
          timestamp(std::chrono::system_clock::now()) {}
};

// 订阅信息
struct Subscription {
    std::string client_id;
    std::vector<std::string> symbols;
    std::chrono::system_clock::time_point created_at;
    
    Subscription(const std::string& id) 
        : client_id(id), created_at(std::chrono::system_clock::now()) {}
};

// WebSocket消息类型
enum class MessageType {
    SUBSCRIBE,
    UNSUBSCRIBE,
    QUOTE_UPDATE,
    ERROR,
    HEARTBEAT
};

// WebSocket消息结构
struct WebSocketMessage {
    MessageType type;
    std::string client_id;
    std::string data;
    std::chrono::system_clock::time_point timestamp;
    
    WebSocketMessage(MessageType t, const std::string& id, const std::string& d)
        : type(t), client_id(id), data(d), 
          timestamp(std::chrono::system_clock::now()) {}
};

} // namespace yquote 